<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item>购票系统</el-breadcrumb-item>
      <el-breadcrumb-item>电影详情</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="box">
      <div>
        <img :src="list.poster" alt style="width:336px;height:500px"/>
      </div>
      <div class="miaoshu">
        <h2 style="font-size:30px;color:red;font-weight: 600;">片名：{{list.name}}</h2>
        <h2 style="font-size:20px;">导演：{{list.director}}</h2>
        <h2>类型：{{list.category}}</h2>
        <h2>国家：{{list.nation}}</h2>
        <h2>评分：{{list.grade}}</h2>
        <p>内容简介：{{list.synopsis}}</p>
      </div>
      <div class="yan">
        <el-popover 
        placement="top" 
        width="200" 
        trigger="hover"
         v-for="(item,i) in listt.slice(1,listt.length)" :key="i"
        >
            <p>{{item.name}}饰：{{item.role}}</p>
          <el-button slot="reference"><img :src="item.avatarAddress" alt style="width:178;heigth:246"></el-button>
        </el-popover>
      </div>
      <div class="zuihou">
        <h2 style="font-size:20px;font-weight: 600;">场次：{{list.filmType.name}}巨幕激光厅</h2>
        <h6 v-if="dengji>0.1">
          <p style="text-align:right;margin-right:10px">原价: <span  style="text-decoration:line-through" > ¥ {{list.grade*6 }}</span></p>
          <p style="text-align:right;margin-right:10px;color:#000">会员折扣: <span  style="color:#F56C6C" > ¥ {{list.grade*6*(1-dengji) }}</span></p>
        </h6>
        <h6 v-else>
          <p style="text-align:right;margin-right:10px">单价: <span  style="color:#F56C6C" > ¥ {{list.grade*6 }}</span></p>
          <p style="text-align:right;margin-right:10px;color:green">暂无折扣，快去成为会员吧！</p>
        </h6>
        <div class="margintop20">
            <span style="color:#fff">购买数量:</span>
            <!-- 计数器 -->
            <el-input-number v-model="count" :min="1"  ></el-input-number>
        </div>
        <div class="margintop20">
            <el-button type="success" size="mini"  @click="addToshopcar"> <span class="el-icon-circle-plus"></span> 加入购物车</el-button>
            <el-button type="danger" size="mini" @click="$router.push({name:'buycar'})" > <span class="el-icon-shopping-cart-1"></span> 查看我的商品(购买)</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { detaillist,addtocar } from "@/api";
export default {
  data() {
    return {
      list: [],
      listt: [],
      count:1,
      dengji:null,
      price:null,
    };
  },
  mounted() {
    this.dengji = sessionStorage.getItem('roleid')/20;
    console.log(this.dengji);
    // console.log(this.$route.params.filmId);
    detaillist({
      filmId: this.$route.params.filmId,
    }).then((res) => {
      if (res.type) {
        this.list = res.result.data.film;
        this.listt = res.result.data.film.actors;
        // console.log(this.list, this.listt);
        if(this.dengji > 0.1){
            this.price = this.list.grade*6*(1-this.dengji)
          }else{
            this.price = this.list.grade*6
          }
          console.log(this.price);
      }
    });
    // console.log(this.price);
  },
  methods:{
    addToshopcar(){
      // console.log(this.$route.params.filmId);
      // console.log(this.list);
      // console.log(this.count);
      addtocar({
        filmId:this.$route.params.filmId*localStorage.getItem("mobile"),//将filmId处理成为一个唯一值，传入数据库，做查询的依据
        list:this.list,
        count:this.count*1,
        price:this.price
      })
      .then(res=>{

      })
    }
  }
};
</script>

<style lang="scss" scoped>
::-webkit-scrollbar {
  width: 0px;
}
::v-deep .el-breadcrumb__inner {
  color: rgb(240, 124, 124) !important;
}
.el-breadcrumb {
  font-size: 30px;
  
}
.box {
  width: 90%;
  height: 510px;
  border: 10px dotted black;
  padding: 10px 0 10px 20px;
  margin: 0 auto;
  background: rgba(250, 248, 248, 0.3);
  display: flex;
}
.miaoshu {
  width: 220px;
  height: 100%;
  box-sizing: border-box;
  margin-left: 20px;
  border-radius: 10px;
  background: blanchedalmond;
  padding: 10px;
  h2 {
    margin: 10px 0;
    font-size: 18px;
  }
  p {
    color: rgb(9, 62, 122);
    position: relative;
    line-height: 20px;
    max-height: 200px;
    overflow: hidden;
  }
  p::after {
    content: "...";
    position: absolute;
    bottom: 0;
    right: 0;
    padding-left: 40px;
    background: -webkit-linear-gradient(left, transparent, #fff 55%);
    background: -o-linear-gradient(right, transparent, #fff 55%);
    background: -moz-linear-gradient(right, transparent, #fff 55%);
    background: linear-gradient(to right, transparent, #fff 55%);
  }
}
::v-deep .yan {
  width: 220px;
  height: 100%;
  box-sizing: border-box;
  margin-left: 20px;
  border-radius: 10px;
  background: blanchedalmond;
  overflow: auto;
  img {
    width: 100%;
    height: 100%;
  }
}
::v-deep.yan:hover span {
  display: block;
}
.zuihou{
  margin-top: 80px;
  margin-left: 100px;
  width: 300px;
  height: 300px;
  background: url(../../assets/images/timg12.jpg);
  background-size: 100% 100%;
  text-align: center;
  line-height: 50px;
  color: #fff;
}
</style>